package zb.filter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;
import org.apache.commons.lang.StringUtils;
import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Component
public class PowerFilter extends ZuulFilter {
    @Override
    public String filterType() {
        return FilterConstants.PRE_TYPE;
    }

    @Override
    public int filterOrder() {
        return 0;
    }

    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() throws ZuulException {
////        RequestContext currentContext = RequestContext.getCurrentContext();
////        HttpServletRequest request = currentContext.getRequest();
////        String token = request.getParameter("token");
////        if(StringUtils.isEmpty(token)){
////            //组织路由
////            currentContext.setSendZuulResponse(false);
////            //返回给客户端的信息
////            currentContext.setResponseStatusCode(401);
////            currentContext.setResponseBody("{'msg':'not login'}");
////            return "no";
//        }
//        return "next";
        return null;
    }

}
